//
//  Top_upCell.m
//  WanCaiC8
//
//  Created by tangang on 2018/4/19.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "Top_upCell.h"

@implementation Top_upCell{
    UIImageView *icon;
    QXLable     *labName;
    UIImageView *selectImage;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        icon=[[UIImageView alloc]init];
        [self.contentView addSubview:icon];
        [icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView);
            make.left.equalTo(self.contentView).with.offset(14);
            make.size.mas_equalTo(CGSizeMake(25, 25));
        }];
        
        labName=[[QXLable alloc]initWithFount:10];
        [self.contentView addSubview:labName];
        [labName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(icon.mas_right).with.offset(23);
            make.top.bottom.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(200, 44));
        }];
        
        selectImage=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"card_selected"]];
        [self.contentView addSubview:selectImage];
        [selectImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).with.offset(-10);
            make.centerY.equalTo(self.contentView);
            make.size.mas_equalTo(selectImage.image.size);
        }];
        
        UIView *line=[[UIView alloc]init];
        line.backgroundColor=DEFAULTBGCOLOR;
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(icon);
            make.top.right.equalTo(self.contentView);
            make.height.mas_equalTo(@.7);
        }];
    }
    return self;
}

- (void)setType:(NSInteger)type andIsSelect:(BOOL)isSelect{
    NSString *strName;
    if (type==0) {
        icon.image=[UIImage imageNamed:@"pay_wechat"];
        strName=@"微信支付\n快速支付，免手续费";
    }else{
        icon.image=[UIImage imageNamed:@"pay_alipay"];
        strName=@"支付宝 \n快速支付，免手续费";
    }
    NSMutableAttributedString *attStr=[[NSMutableAttributedString alloc]initWithString:strName];
    [attStr addAttribute:NSForegroundColorAttributeName value:DEFAULTTEXTBLACKCOLOR range:NSMakeRange(0, 4)];
    [attStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, 4)];
    labName.attributedText=attStr;
    if (isSelect) {
        selectImage.image=[UIImage imageNamed:@"card_selected"];
    }else{
        selectImage.image=[UIImage imageNamed:@"card_noSelected"];
    }
}

@end
